package com.sline.Regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Demo1_Pattern {
    public static void main (String[] args) {
        demo1();
    }

    // 获取字符串中的手机号
    private static void demo1() {
        String s = "我的手机号码是18999999999, 曾今用过18987654321, 还用过18812345678";

        Pattern p = Pattern.compile("1[3578]\\d{9}");
        Matcher m = p.matcher(s);

        while (m.find()) {
            System.out.println(m.group());
        }
    }
}
